import { 
  createStackNavigator,
  createMaterialTopTabNavigator,
  createBottomTabNavigator,
  createSwitchNavigator,
  createAppContainer
} from 'react-navigation'

import {connect} from 'react-redux'
import {createReactNavigationReduxMiddleware, reduxifyNavigator} from 'react-navigation-redux-helpers';
export const rootCom = 'Init';//设置根路由


import StartUp from '../page/StartUp.js'

// import MallSearch from '@/page/mall/mallSearch/MallSearch.js'

import Login from '../page/registAndLogin/login/Login.js'
import Regist from '../page/registAndLogin/regist/Regist.js'
import ForgetPwd from '../page/registAndLogin/forgetPwd/ForgetPwd.js'

import Index from '../page/Index.js'
// import Details from '@/page/home/Details.js'

import MyInfo from '../page/myself/myInfo/MyInfo.js'
// import SystemSet from '../page/myself/systemSet/SystemSet.js'
import MyOrder from '../page/myself/myOrder/MyOrder.js'
// import IntegralRecord from '../page/myself/integralRecord/IntegralRecord.js'

import CustomTheme from '../page/myself/customTheme/CustomTheme'

import CourseRenew from '../page/course/courseRenew/CourseRenew.js'
import Leave from '../page/course/leave/Leave.js'

// 启动页导航
const InitNavigator = createStackNavigator({
  StartUp: {
    screen: StartUp,
    navigationOptions: {
      header: null
    }
  }
});

// 登录页导航
const LoginNavigator = createStackNavigator({
  StartUp: {
    screen: Login,
    navigationOptions: {
      header: null
    }
  }
});


// 注册页导航
const RegistNavigator = createStackNavigator({
  StartUp: {
    screen: Regist,
    navigationOptions: {
      header: null
    }
  }
});


// 忘记密码导航
const ForgetPwdNavigator = createStackNavigator({
  StartUp: {
    screen: ForgetPwd,
    navigationOptions: {
      header: null
    }
  }
});


// 主导航
const MainNavigator = createStackNavigator({
  Index: {
    screen: Index,
    navigationOptions: {
      header: null
    }
  },
  // MallSearch: {
  //   screen: MallSearch,
  //   navigationOptions: {
  //     header: null
  //   }
  // },
  CourseRenew: {
    screen: CourseRenew,
    navigationOptions: {
      header: null
    }
  },
  Leave: {
    screen: Leave,
    navigationOptions: {
      header: null
    }
  },
  MyInfo: {
    screen: MyInfo,
    navigationOptions: {
      header: null
    }
  },
  MyOrder: {
    screen: MyOrder,
    navigationOptions: {
      header: null
    }
  },
  // IntegralRecord: {
  //   screen: IntegralRecord,
  //   navigationOptions: {
  //     header: null
  //   }
  // },
  // SystemSet: {
  //   screen: SystemSet,
  //   navigationOptions: {
  //     header: null
  //   }
  // },
  CustomTheme: {
    screen: CustomTheme,
    navigationOptions: {
      header: null
    }
  }

},{
  navigationOptions: {
    header: null,// 可以通过将header设为null 来禁用StackNavigator的Navigation Bar
  }
});





export const RootNavigator =  createSwitchNavigator({
    Init: InitNavigator,
    Main: MainNavigator,
    Login: LoginNavigator,
    Regist: RegistNavigator,
    ForgetPwd: ForgetPwdNavigator
}, {
  navigationOptions: {
    header: null,
  }
});

export const middleware = createReactNavigationReduxMiddleware(
  'root',
  state => state.nav
);

const AppWithNavigationState = reduxifyNavigator(RootNavigator, 'root');

const mapStateToProps = state => ({
  state: state.nav,//v2
});

export default connect(mapStateToProps)(AppWithNavigationState);
